package com.youku.plugins.interaction.view
{
   import flash.display.Sprite;
   import flash.display.MovieClip;
   import com.youku.plugins.interaction.model.data.InteractionSwfData;
   import flash.display.DisplayObject;
   
   public class InteractionItem extends Sprite
   {
      
      public function InteractionItem(param1:MovieClip, param2:InteractionSwfData) {
         super();
         this._mainMc = param1;
         this._swfData = param2;
         this._type = param2.name;
      }
      
      private var _swfItem = null;
      
      private var _mainMc:MovieClip;
      
      private var _type:String;
      
      private var _swfData:InteractionSwfData;
      
      public function dispose() : void {
         if((this._swfItem) && (this._mainMc.contains(this._swfItem)))
         {
            this._mainMc.removeChild(this._swfItem);
         }
         try
         {
            this._swfItem.dispose();
         }
         catch(e:Error)
         {
         }
         this._swfItem = null;
      }
      
      public function addItem(param1:DisplayObject, param2:Object = null) : void {
         this._swfItem = param1;
         try
         {
            this._mainMc.addChildAt(this._swfItem as DisplayObject,0);
            this._swfItem.init(param2);
         }
         catch(e:Error)
         {
         }
      }
      
      public function jsCallAs(param1:Object) : void {
         var data:Object = param1;
         if(this._swfItem)
         {
            try
            {
               this._swfItem.jsCallAs(data);
            }
            catch(e:Error)
            {
            }
         }
      }
      
      public function get type() : String {
         return this._type;
      }
      
      public function get swfData() : InteractionSwfData {
         return this._swfData;
      }
      
      public function hide() : void {
         if(this._swfItem)
         {
            try
            {
               this._swfItem.visible = false;
            }
            catch(e:Error)
            {
            }
         }
      }
      
      public function show() : void {
         if(this._swfItem)
         {
            try
            {
               this._swfItem.visible = true;
            }
            catch(e:Error)
            {
            }
         }
      }
   }
}
